<template>
	<view>
		<view class="head flex flex-a-center">
			<view class="head-text">总金额</view>
			<view class="head-num">{{total_amount|| 0}}</view>
		</view>
		<view class="list">
			<view class="list-item" v-for="(item,index) in dataList" :key="index">
				<view class="time">{{item.create_time}}</view>
				<view class="info flex">
					<view class="text">{{item.reason}}</view>
					<view class="money">{{item.amount}}</view>
				</view>
			</view>
			<mix-load-more :status="loadMoreStatus"></mix-load-more>
		</view>
	</view>
</template>

<script>
	import henglang from '@/common/common.js';
    export default {
        data() {
            return {
				dataList:[],
				page:1,
				total_pages:1,
				postData:{},
				loadMoreStatus:1,
				total_amount:0
            };
        },
        methods: {
			getData(type){
				let that = this
				if(that.page <= that.total_pages){
					henglang.get('Retreat_Granary/granaryDetail',that.postData,true,function(res){
						if(type=='loadMore'){
							that.dataList = that.dataList.concat(res.data.data.data)
						}else{
							that.dataList = res.data.data.data
							that.total_pages = res.data.data.total_pages
							that.loadMoreStatus = that.total_pages <= 1 ? 2:0
							that.total_amount = res.data.data.total_amount
						}
					})
				}else{
					that.loadMoreStatus = 2
				}
			}
        },
		onLoad(option) {
			let that = this
			this.postData = option
			this.postData.page = 1
			this.getData()
        },
		onReachBottom() {
			this.page++
			this.getData('loadMore')
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #f1f1f1;
	}
	.flex{
		display: flex;
		&1{
			flex: 1;
		}
		&-a-center{
			align-items: center;
		}
		&-a-start{
			align-items: flex-start;
		}
		&-a-end{
			align-items: flex-end;
		}
		&-j-center{
			justify-content: center;
		}
		&-j-start{
			justify-content: flex-start;
		}
		&-j-end{
			justify-content: flex-end;
		}
	}
	.head{
		height: 110rpx;
		justify-content: space-between;
		padding: 0 100rpx;
		background-color: #FFFFFF;
		margin-bottom: 20rpx;
		&-text{
			font-size: 34rpx;
		}
		&-num{
			font-size: 50rpx;
		}
	}
	
	.list{
		background-color: #FFFFFF;
		padding: 0 20rpx;
		&-item{
			padding: 25rpx 35rpx;
			border-bottom: 1px solid #e6e6e6;
			.time{
				color: #808080;
				font-size: 28rpx;
			}
			.text{
				font-size: 34rpx;
			}
			.money{
				font-size: 40rpx;
			}
			.info{
				justify-content: space-between;
				padding-top: 10rpx;
			}
		}
	}
</style>
